package com.briup;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class DelectById {
  public static void main(String[] args) throws IOException {
      String resource = "mybatis-config.xml";
      InputStream inputStream = Resources.getResourceAsStream(resource);
      SqlSessionFactory build = new SqlSessionFactoryBuilder().build(inputStream);
      //build.openSession(true);设置自动提交事务,默认为false
      SqlSession sqlSession = build.openSession(true);
      try{
          StuMapper mapper = sqlSession.getMapper(StuMapper.class);
          boolean b = mapper.deleteById(1);
      System.out.println(b);
      }finally{
          sqlSession.close();
      }

  }
}
